﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Storedlistt
{
    class Program
    {
        static void Main(string[] args)
        {
            // 创建一个SortedList对象
            SortedList mySL = new SortedList();
            mySL.Add("1", "小");
            mySL.Add("2", "波");
            mySL.Add("3", "❤");
            //列举SortedList的属性、键、值
            
            Console.WriteLine("  元素数:    {0}", mySL.Count);
            Console.WriteLine("  键 和 值:");
           

            //region SortedList获得键、值列表
            SortedList mySL1 = new SortedList();
            mySL1.Add(0, "朝");
            mySL1.Add(1, "暮");
            mySL1.Add(3, "暮");
            mySL1.Add(2, "朝");
            mySL1.Add(4, "是");
            mySL1.Add(5, "你");

            //获得指定索引处的键和值
            int myIndex = 3;
            Console.WriteLine("键为 {0} 所代表的值是 {1}.", myIndex, mySL1.GetByIndex(myIndex));

            // 获得SortedList中的键列表和值列表
            IList myKeyList = mySL1.GetKeyList();
            IList myValueList = mySL1.GetValueList();

            // Prints the keys in the first column and the values in the second column.
            Console.WriteLine("\t-键-\t-值-");
            for (int i = 0; i < mySL1.Count; i++)
                Console.WriteLine("\t{0}\t{1}", myKeyList[i], myValueList[i]);

        }
    }
}
